import req from './req.js';
import HttpError from "./error.js";

export  function regnewAccount( udata ){
    return new Promise( function( resolve , reject ){
        req.request({
            baseurl: process.env.VUE_APP_HOST,
            url:  "/user/regist_account",
            method: "post",
            data: {
                account: udata.account,
                password: udata.password
            },
            header:{
                "Content-Type" : "application/json;charset=utf-8"
            }
        }
        ).then( res=>{
            resolve( res );
        }).catch(err=>{
            // console.log("register: ", err);
            reject( err );
        })
    } );
     
    // console.log("request: ",res);
    // if( res.status == 200){
    //     return res.data;
    // }else{
    //     console.log("http error: ",HttpError);
    //     HttpError.checkStatus(400);
    // }
    
}